<%@ page contentType="text/html;charset=utf-8"%>
<%@taglib prefix="s" uri="/struts-tags"%>
<html>
	<head>
		<title>查看系统用户列表</title>
		<link rel="stylesheet"
			href="<%=request.getContextPath()%>/css/common.css" type="text/css" />
		<script type='text/javascript'
			src='<%=request.getContextPath()%>/dwr/interface/systemUserMgrAction.js'></script>
		<script type='text/javascript'
			src='<%=request.getContextPath()%>/dwr/engine.js'></script>
		<script type='text/javascript'
			src='<%=request.getContextPath()%>/dwr/util.js'></script>
		<script type="text/javascript"
			src="<%=request.getContextPath()%>/js/N13FormValidation-2.js"></script>
		<script type='text/javascript'
			src='<%=request.getContextPath()%>/js/jquery-latest.pack.js'></script>
		<script type='text/javascript'
			src='<%=request.getContextPath()%>/js/noConflictOfJquery.js'></script>
		<script type='text/javascript'
			src='<%=request.getContextPath()%>/js/forCSS.js'></script>
		<script type="text/javascript">
	//全局变量
	var viewed = -1;
	var eid ;
	var totalcount =-1;
	var page;
	
	function listSearchTotalSystemUserGroup(){
	systemUserMgrAction.getSystemUserGroupTotalRows(listsystemusergrouprowscb);
	}
	 
	var listsystemusergrouprowscb =  function listsystemuserows_cb(rows){
			totalcount = rows;	 //给总行数赋值
			systemUserMgrAction.listAllSysUserGroupListByPage(1,totalcount,listsugcallback);	
	}
	var listsugcallback = function listsugcallbackfunc(suglst){
		if($('pageTable').style.visibility == 'hidden'){
			$('pageTable').style.visibility = 'visible';
		}
		DWRUtil.removeAllRows('ttb', { filter:function(tr) {
		      return (tr.id != "pattern");
			    }});
		var al,id;
		 for (var i =0; i < suglst.length ; i++) {
			  al = suglst[i];
			  id = al.systemusergroupid;
			 dwr.util.cloneNode("pattern", { idSuffix:id });
		     dwr.util.setValue("tableid"+id, al.systemusergroupid); //隐藏项
		     dwr.util.setValue("tablepid"+id, al.systemuserpermissionid);//隐藏项
		     dwr.util.setValue("tablename"+id, al.systemusergroupname);
		     dwr.util.setValue("tablevalue"+id, al.systemusergroupvalue);
		     dwr.util.setValue("cbx" + id, al.apartmentid);
		 	 $("pattern" + id).style.display= "";
		   }
		 	setPageInfo();
		 	tbCSS();
	}
	
	
	function setPageInfo(){
        $('pageTd').innerHTML = '';
        systemUserMgrAction.getPage({     
            callback:function(data){
                page = data;
                if(page.totalPage != 0){
                    var pageSpan = document.createElement('span');
                    pageSpan.innerHTML = '共 '+totalcount+' 条 '+'   第 '+page.currentPage+' 页    共'+page.totalPage+' 页 ';
                    $('pageTd').appendChild(pageSpan);
                    var aFirst = document.createElement('a');
                    aFirst.setAttribute('href','javascript:getFirstData()');
                    aFirst.innerHTML = '首页';
                    $('pageTd').appendChild(aFirst);
                    var aPrevious = document.createElement('a');
                    aPrevious.setAttribute('href','javascript:getPreviousData()');
                    aPrevious.innerHTML = '上一页 ';
                    $('pageTd').appendChild(aPrevious);
                    var aNext = document.createElement('a');
                    aNext.setAttribute('href','javascript:getNextData()');
                    aNext.innerHTML = '下一页 ';
                    $('pageTd').appendChild(aNext);
                    var aLast = document.createElement('a');
                    aLast.setAttribute('href','javascript:getLastData()');
                    aLast.innerHTML = '尾页';
                    $('pageTd').appendChild(aLast);    
                }               
            }
        });
        $('loading').style.display = 'none';
    }    

	function getFirstData(){
		page.currentPage = 1;
		getDataPerPage();
	}
	
	 function getPreviousData(){
        if(page.currentPage>1){
            page.currentPage--;
        }
        getDataPerPage();
    }
    
    function getNextData(){
        if(page.currentPage<page.totalPage){
            page.currentPage++;
        }
        getDataPerPage();
    }
	
	function getLastData(){
		page.currentPage = page.totalPage;
		getDataPerPage();
	}
	
	
	function getDataPerPage(){
		$('loading').style.display = 'block';
		systemUserMgrAction.listAllSysUserGroupListByPage(page.currentPage,totalcount,listsugcallback);	
	}	
	function delClicked(eleid){
		//得到的eleid为"mydelete{id}"
		var sugid = eleid.substring(8);
		  //alert(ap_id);
		  systemUserMgrAction.deleteSysUserGroupById(sugid,delcb)
		}
	var delcb = function del_cb(stas){
			alert(stas);
			listSearchTotalSystemUserGroup();
		}
		</script>
	<body onload="javascript:listSearchTotalSystemUserGroup()">
		<div id="page_container">
			<%@   include file="usergroupbanner.jsp"%>
			<div id="systemusergrpinfo">
				<h2>
					系统用户组
				</h2>
				<table id="MyTable" class="table_common table_list_style">
					<thead>
						<tr>
							<th>
								<div width="12%">
									选择
								</div>
							</th>
							<th>
								<div width="30%">
									用户组名
								</div>
							</th>
							<th>
								<div width="30%">
									用户组权值
								</div>
							</th>
							<th>
								<div width="28%">
									删除
								</div>
							</th>
						</tr>
					</thead>
					<tbody id="ttb">
						<tr id="pattern" style="display: none;">
							<td>
								<div>
									<input type="checkbox" id="cbx" name="cbx" />
								</div>
							</td>
							<!-- 隐藏项 -->
							<div id="tableid" style="display: none">
							</div>
							<div id="tablepid" style="display: none">
							</div>
							<!-- 隐藏项 -->
							<td>
								<div id=tablename>
								</div>
							</td>
							<td>
								<div id="tablevalue">
								</div>
							</td>
							<td>
								<div>
									<a href="#" id="mydelelt"
										onclick="javascript:if(confirm('确认删除！')) delClicked(this.id)">
										<img src="../images/010.gif" width="9" height="9" /> </a>
								</div>
							</td>
						</tr>
					</tbody>
				</table>
				<table id="pageTable" align="center"
					style="visibility: hidden; margin-top: 30px; font: 12px;"
					class="navigator">
					<tr>
						<td id="pageTd"></td>
					</tr>
				</table>
				<div id="loading"
					style="display: none; margin-top: 20px; text-align: center; color: red; font: 13px;">
					Loading...
				</div>
			</div>
		</div>
	</body>
</html>
